unit siAutoUtils;

interface

procedure _trace(s:String); overload;
procedure _trace(fmt:String; vals: array of const); overload;
procedure StartLogging;


implementation

uses
  {$ifdef siAuto}siAuto, {$endif} System.SysUtils;

procedure _trace(s:String);
begin
  {$ifdef siAuto}
  siMain.LogMessage(s);
  {$endif}
end;

procedure _trace(fmt:String; vals: array of const);
begin
  {$ifdef siAuto}
  _trace( Format(fmt,vals) );
  {$endif}
end;

procedure StartLogging;
var
  aParam: string;
  FilePath: string;
begin
  FilePath := ExtractFilePath( ParamStr(0) ) + 'Log';
  if not DirectoryExists(FilePath) then ForceDirectories( FilePath );
  FilePath := FilePath + '\' + 'Log.sil';
  aParam := format('file(filename="%s", append="true", buffer="0", rotate="daily"), pipe(reconnect="true", reconnect.interval="60")', [ FilePath ] );

  si.Connections := aParam;
  si.Enabled := True;
end;


end.
